package cn.tedu.exec;

import java.util.Arrays;

/**复写案例*/
public class TestDog02 {
    public static void main(String[] args) {
        Dog2 dog = new Dog2();
        //dog.name = "小狗狗";
        dog.setName("小狗狗");
        dog.age = 3;
        dog.host = "小明";
        dog.kind = "中华田园犬";
        //System.out.println(dog.name);
        dog.price = 666;
        System.out.println(dog.getName());
        System.out.println(dog.age);
        System.out.println(dog.host);
        System.out.println(dog.kind);
        System.out.println(dog.price);
        dog.run();
        dog.eat(5);
        dog.sleep(6);
//        dog.play(dog.host);
        String g = dog.play("小明","骨头");
        System.out.println(g);

    }

}
class Dog2{
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    //2.属性:名字name 年龄age 品种kind 主人host 价格price
    //3.1封装所有的属性
    private String name;
    int age;
    String kind;
    String host;
    double price;
    //方法格式:修饰符 返回值类型 方法名(参数列表){方法体}
    //4.1添加小狗类的功能1
    //跑run:无参,无返回值,打印:小狗Dog跑的老快啦~
    public void run(){
        System.out.println("小狗狗跑的老快了");
    }
    //4.2添加小狗类的功能2
    //吃eat:参数int n,无返回值,打印:小狗Dog今晚要吃n根肉骨头
    public int eat (int n){
        return n;
    }
    //4.3添加小狗类的功能3
    //睡觉sleep:参数double num,无返回值,打印:小狗Dog今天一共睡了num个小时
    public void sleep(double num){
        System.out.println("小狗狗今天一共睡了"+num+"个小时");
    }
    //4.4添加小狗类的功能4
    //玩play:参数String host,返回值String"飞盘",打印:小狗与主人host玩的很开心
    public String play(String host,String toy){
        System.out.println("小狗狗与主人"+host+"玩"+toy+"玩的很开心");
        bark();
        return toy;
    }
    //4.5添加小狗类的功能5
    //叫bark:打印:小狗喜欢汪汪叫,此方法要封装,玩的时候才叫
    private void bark(){
        System.out.println("小狗喜欢汪汪叫");
    }
}
